<html>
    <head>
        <style type="text/css">
            body {
                background: #FFFFFF url("images/bg.png") repeat;
                background-attachment:fixed;
            }
            .button 
            {
                background-color:beige;
                cursor:pointer; }

            .btn
            {


                background-color:#FFF5EE;
                cursor:pointer;
            }
            .btn1
            {
                border-radius: 5px;
                box-shadow: #EEE6E6 3px 3px 3px; 
                border: 1px solid #892525;  
                background-color:#F8F1D4;
                cursor:pointer;
            }
        </style>
    </head>
</html>
<?php
include 'conn.php';
$activityList="";
$qry = "SELECT count(*)
	FROM attendancerecord, client, centre 
        WHERE DATE(SignInTimeStamp)=CURDATE() 
        AND attendancerecord.NRIC = client.NRIC 
        AND attendancerecord.CentreId = centre.CentreId";
$result = mysql_query($qry);
while ($row = mysql_fetch_array($result)) {
    echo "<h3 style='vertical-align:right;text-align:right;font-size:18px'><b>Headcount: " . $row['count(*)'] . " </b></h3>";
}


include 'conn.php';
if($userType!="System Admin")
{$userType=$_SESSION["userType"];
$centreName = $_SESSION["centreName"];
    
    $get = mysql_query("Select CentreId from Centre where CentreName='$centreName'");
    while($row=mysql_fetch_array($get))
    {
        $centreId = $row['CentreId'];
    }
    $result = mysql_query( "SELECT attendancerecord.NRIC, client.CustomerName, 
            centre.CentreName, attendancerecord.SignInTimeStamp
	FROM attendancerecord, client, centre 
        WHERE DATE(SignInTimeStamp)=CURDATE() 
        AND attendancerecord.CentreId= $centreId
        AND attendancerecord.NRIC = client.NRIC 
        AND attendancerecord.CentreId = centre.CentreId");
}
else
{
    $result = mysql_query( "SELECT attendancerecord.NRIC, client.CustomerName, 
            centre.CentreName, attendancerecord.SignInTimeStamp
	FROM attendancerecord, client, centre 
        WHERE DATE(SignInTimeStamp)=CURDATE() 
        AND attendancerecord.NRIC = client.NRIC 
        AND attendancerecord.CentreId = centre.CentreId");
}

echo "<p>
            </p>
            <table class='tablereport' id='tblAttendance' border='5'  valign='top'><tr >
	<td name='Number'>
	<font face='Arial, Helvetica, sans-serif'>Number</font>
	</td>
	<td name='NRIC'>
	<font face='Arial, Helvetica, sans-serif'>NRIC</font>
	</td>
	<td name='CentreId'>
	<font face='Arial, Helvetica, sans-serif'>CustomerName</font>
	</td>
	<td name='CentreName' >
	<font face='Arial, Helvetica, sans-serif'>Centre Name</font>
	</td>
	<td name='Date' >
	<font face='Arial, Helvetica, sans-serif'>Date</font>
	</td>
	<td name='ActivityName' >
	<font face='Arial, Helvetica, sans-serif'>Activity Name</font>
	</td>
        
	</tr>";
$count = 1;
while ($row = mysql_fetch_array($result)) {
    echo"<tr>
	<td >
	<font face='Arial, Helvetica, sans-serif'>" . $count . "</font>
	</td >
	<td >
	<font face='Arial, Helvetica, sans-serif'>" . $row['NRIC'] . "</font>
	</td >
	<td >
	<font face='Arial, Helvetica, sans-serif'>" . $row['CustomerName'] . "</font>
	</td>
	<td >
	<font face='Arial, Helvetica, sans-serif'>" . $row['CentreName'] . "</font>
	</td>
	<td>
	<font face='Arial, Helvetica, sans-serif'>" . $today = date('j F, Y') . "</font>
	</td>";
    $tempNRIC = $row['NRIC'];
    $result1 = mysql_query( "SELECT activity.ActivityName 
            FROM activity, activityrecord
            WHERE activity.ActivityId = activityrecord.ActivityId
            AND activityrecord.NRIC = '$tempNRIC' and date(activityrecord.Date)=CURDATE()");
    while ($row1 = mysql_fetch_array($result1)) {
        $activityList .=$row1['ActivityName'] . ", ";
    }
    if (!empty($activityList)) {
        
        echo"
        <td>
	<font face='Arial, Helvetica, sans-serif'>" . $activityList . "</font>
	</td>
	</tr>";
    } else {
        echo"
        <td>
	<font face='Arial, Helvetica, sans-serif'>No activity recorded!</font>
	</td>
        
	</tr>";
    }
    $count++;
    $activityList = "";
}
echo "</table>";
?>
